using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

using PCSUtils.Framework.TableFrame;
using PCSUtils.Utils;
using PCSUtils.Log;
using PCSComUtils.Common;
using PCSComUtils.Common.BO;
using PCSComUtils.MasterSetup.DS;
using PCSComUtils.MasterSetup.BO;
using PCSComProduct.Items.BO;
using PCSComProduct.Items.DS;
using PCSComProduct.Costing.BO;
using PCSComProduct.Costing.DS;
using PCSComUtils.PCSExc;

namespace PCSProduct.Items
{
	/// <summary>
	/// Summary description for ItemCostDetail.
	/// </summary>
	public class ItemCostDetail : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button btnClose;
		private System.Windows.Forms.Button btnHelp;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		private const string THIS = "PCSProduct.Items.ItemCostDetail";

		const string GRID_COL_NAME ="NAME";
		const string GRID_COL_CAPTION = "CAPTION";
		const string GRID_COL_WIDTH = "WIDTH";

		private int intProductID;
		private int intCCNID;
		private C1.Win.C1TrueDBGrid.C1TrueDBGrid tgridViewData;
		DataTable dtGridDesign;
		private EnumAction enumAction ;	

		public ItemCostDetail()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		public ItemCostDetail(int pintProductID, int pintCCNID)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
			intProductID = pintProductID;
			intCCNID = pintCCNID;

		}
		//**************************************************************************              
		///    <Description>
		///       Store the designed inteface of the grid 
		///       and later will get this setting back at runtime
		///       - Store Caption
		///       - Store Width
		///       - 
		///    </Description>
		///    <Inputs>
		///       
		///    </Inputs>
		///    <Outputs>
		///       
		///    </Outputs>
		///    <Returns>
		///       
		///    </Returns>
		///    <Authors>
		///       THIENHD
		///    </Authors>
		///    <History>
		///       15-Dec-2004
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************

		private void KeepTheGridDesign()
		{
			const string GRID_TABLE_NAME ="GRID";
			try 
			{
				//const string COL_ALIGN = "ALIGN";
				DataColumn dcolMyColumn ; 
				dtGridDesign = new DataTable(GRID_TABLE_NAME);


				DataColumn[] dcolKey = new DataColumn[1];
			

				dcolMyColumn = new DataColumn();
				dcolMyColumn.DataType = typeof(string);
				dcolMyColumn.ColumnName= GRID_COL_NAME;
				dtGridDesign.Columns.Add(dcolMyColumn);
				dcolKey[0] = dcolMyColumn; //set this column as the primary key

				dcolMyColumn = new DataColumn();
				dcolMyColumn.DataType = typeof(string);
				dcolMyColumn.ColumnName= GRID_COL_CAPTION;
				dtGridDesign.Columns.Add(dcolMyColumn);


				dcolMyColumn = new DataColumn();
				dcolMyColumn.DataType = typeof(string);
				dcolMyColumn.ColumnName= GRID_COL_WIDTH;
				dtGridDesign.Columns.Add(dcolMyColumn);

				dtGridDesign.PrimaryKey = dcolKey;

				DataRow drNewRow;
				for (int i=0; i<tgridViewData.Columns.Count;i++)
				{
					if (tgridViewData.Columns[i].DataField.Trim() != String.Empty)
					{
						drNewRow = dtGridDesign.NewRow();
						drNewRow[GRID_COL_NAME] = tgridViewData.Columns[i].DataField;
						drNewRow[GRID_COL_CAPTION] = tgridViewData.Columns[i].Caption;
						drNewRow[GRID_COL_WIDTH] = tgridViewData.Splits[0].DisplayColumns[i].Width;
						dtGridDesign.Rows.Add(drNewRow);
					}
				}
				//dtGridDesign.PrimaryKey = new DataColumn() {}
				//return dtGridDesign;

				//gridSaleOrderLine.Columns[SO_SaleOrderDetailTable.SALEORDERLINE_FLD]
			
			}
			catch (Exception ex) 
			{
				throw ex;
			}
		}
		//**************************************************************************              
		///    <Description>
		///        - Load data into grid
		///    </Description>
		///    <Inputs>
		///       
		///    </Inputs>
		///    <Outputs>
		///       Button will be disable or enable
		///    </Outputs>
		///    <Returns>
		///       
		///    </Returns>
		///    <Authors>
		///       THIENHD
		///    </Authors>
		///    <History>
		///       15-Dec-2004
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************

		private void LoadDetailData()
		{
			const string DECIMAL_FORMAT = "Standard";
			const string COMPONENTCOST_FLD = "ComponentCost";
			const string VALUEADDEDCOST_FLD = "ValueAddedCost";
			const string ITEMCOST_FLD = "ItemCost";

			try 
			{

				ItemCostDetailBO objItemCostDetailBO = new ItemCostDetailBO();
				DataTable dtData = objItemCostDetailBO.GetListOfCostDetail(intProductID,intCCNID);
				tgridViewData.DataSource = dtData;

				//Center Heading
				for (int i = 0; i < tgridViewData.Splits[0].DisplayColumns.Count; i++)
				{
					tgridViewData.Splits[0].DisplayColumns[i].HeadingStyle.HorizontalAlignment = C1.Win.C1TrueDBGrid.AlignHorzEnum.Center;
				}
				
				//set the caption, width to the designed specification
				for (int i=0; i < dtGridDesign.Rows.Count ; i++) 
				{
					tgridViewData.Columns[dtGridDesign.Rows[i][GRID_COL_NAME].ToString()].Caption = dtGridDesign.Rows[i][GRID_COL_CAPTION].ToString();
					tgridViewData.Splits[0].DisplayColumns[dtGridDesign.Rows[i][GRID_COL_NAME].ToString()].Width = int.Parse(dtGridDesign.Rows[i][GRID_COL_WIDTH].ToString());
				}

				tgridViewData.Columns[COMPONENTCOST_FLD].NumberFormat = DECIMAL_FORMAT;
				tgridViewData.Columns[VALUEADDEDCOST_FLD].NumberFormat = DECIMAL_FORMAT;
				tgridViewData.Columns[ITEMCOST_FLD].NumberFormat = DECIMAL_FORMAT;


			}
			catch (PCSException ex)
			{
				throw ex;
			}
			catch (Exception ex)
			{
				throw ex;
			}


		}


		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ItemCostDetail));
			this.btnClose = new System.Windows.Forms.Button();
			this.btnHelp = new System.Windows.Forms.Button();
			this.tgridViewData = new C1.Win.C1TrueDBGrid.C1TrueDBGrid();
			((System.ComponentModel.ISupportInitialize)(this.tgridViewData)).BeginInit();
			this.SuspendLayout();
			// 
			// btnClose
			// 
			this.btnClose.AccessibleDescription = resources.GetString("btnClose.AccessibleDescription");
			this.btnClose.AccessibleName = resources.GetString("btnClose.AccessibleName");
			this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnClose.Anchor")));
			this.btnClose.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnClose.BackgroundImage")));
			this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnClose.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnClose.Dock")));
			this.btnClose.Enabled = ((bool)(resources.GetObject("btnClose.Enabled")));
			this.btnClose.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnClose.FlatStyle")));
			this.btnClose.Font = ((System.Drawing.Font)(resources.GetObject("btnClose.Font")));
			this.btnClose.Image = ((System.Drawing.Image)(resources.GetObject("btnClose.Image")));
			this.btnClose.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnClose.ImageAlign")));
			this.btnClose.ImageIndex = ((int)(resources.GetObject("btnClose.ImageIndex")));
			this.btnClose.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnClose.ImeMode")));
			this.btnClose.Location = ((System.Drawing.Point)(resources.GetObject("btnClose.Location")));
			this.btnClose.Name = "btnClose";
			this.btnClose.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnClose.RightToLeft")));
			this.btnClose.Size = ((System.Drawing.Size)(resources.GetObject("btnClose.Size")));
			this.btnClose.TabIndex = ((int)(resources.GetObject("btnClose.TabIndex")));
			this.btnClose.Text = resources.GetString("btnClose.Text");
			this.btnClose.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnClose.TextAlign")));
			this.btnClose.Visible = ((bool)(resources.GetObject("btnClose.Visible")));
			this.btnClose.Click += new System.EventHandler(this.button8_Click);
			// 
			// btnHelp
			// 
			this.btnHelp.AccessibleDescription = resources.GetString("btnHelp.AccessibleDescription");
			this.btnHelp.AccessibleName = resources.GetString("btnHelp.AccessibleName");
			this.btnHelp.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnHelp.Anchor")));
			this.btnHelp.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnHelp.BackgroundImage")));
			this.btnHelp.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnHelp.Dock")));
			this.btnHelp.Enabled = ((bool)(resources.GetObject("btnHelp.Enabled")));
			this.btnHelp.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnHelp.FlatStyle")));
			this.btnHelp.Font = ((System.Drawing.Font)(resources.GetObject("btnHelp.Font")));
			this.btnHelp.Image = ((System.Drawing.Image)(resources.GetObject("btnHelp.Image")));
			this.btnHelp.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnHelp.ImageAlign")));
			this.btnHelp.ImageIndex = ((int)(resources.GetObject("btnHelp.ImageIndex")));
			this.btnHelp.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnHelp.ImeMode")));
			this.btnHelp.Location = ((System.Drawing.Point)(resources.GetObject("btnHelp.Location")));
			this.btnHelp.Name = "btnHelp";
			this.btnHelp.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnHelp.RightToLeft")));
			this.btnHelp.Size = ((System.Drawing.Size)(resources.GetObject("btnHelp.Size")));
			this.btnHelp.TabIndex = ((int)(resources.GetObject("btnHelp.TabIndex")));
			this.btnHelp.Text = resources.GetString("btnHelp.Text");
			this.btnHelp.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnHelp.TextAlign")));
			this.btnHelp.Visible = ((bool)(resources.GetObject("btnHelp.Visible")));
			// 
			// tgridViewData
			// 
			this.tgridViewData.AccessibleDescription = resources.GetString("tgridViewData.AccessibleDescription");
			this.tgridViewData.AccessibleName = resources.GetString("tgridViewData.AccessibleName");
			this.tgridViewData.AllowAddNew = ((bool)(resources.GetObject("tgridViewData.AllowAddNew")));
			this.tgridViewData.AllowArrows = ((bool)(resources.GetObject("tgridViewData.AllowArrows")));
			this.tgridViewData.AllowColMove = ((bool)(resources.GetObject("tgridViewData.AllowColMove")));
			this.tgridViewData.AllowColSelect = ((bool)(resources.GetObject("tgridViewData.AllowColSelect")));
			this.tgridViewData.AllowDelete = ((bool)(resources.GetObject("tgridViewData.AllowDelete")));
			this.tgridViewData.AllowDrag = ((bool)(resources.GetObject("tgridViewData.AllowDrag")));
			this.tgridViewData.AllowFilter = ((bool)(resources.GetObject("tgridViewData.AllowFilter")));
			this.tgridViewData.AllowHorizontalSplit = ((bool)(resources.GetObject("tgridViewData.AllowHorizontalSplit")));
			this.tgridViewData.AllowRowSelect = ((bool)(resources.GetObject("tgridViewData.AllowRowSelect")));
			this.tgridViewData.AllowSort = ((bool)(resources.GetObject("tgridViewData.AllowSort")));
			this.tgridViewData.AllowUpdate = ((bool)(resources.GetObject("tgridViewData.AllowUpdate")));
			this.tgridViewData.AllowUpdateOnBlur = ((bool)(resources.GetObject("tgridViewData.AllowUpdateOnBlur")));
			this.tgridViewData.AllowVerticalSplit = ((bool)(resources.GetObject("tgridViewData.AllowVerticalSplit")));
			this.tgridViewData.AlternatingRows = ((bool)(resources.GetObject("tgridViewData.AlternatingRows")));
			this.tgridViewData.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("tgridViewData.Anchor")));
			this.tgridViewData.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("tgridViewData.BackgroundImage")));
			this.tgridViewData.BorderStyle = ((System.Windows.Forms.BorderStyle)(resources.GetObject("tgridViewData.BorderStyle")));
			this.tgridViewData.Caption = resources.GetString("tgridViewData.Caption");
			this.tgridViewData.CaptionHeight = ((int)(resources.GetObject("tgridViewData.CaptionHeight")));
			this.tgridViewData.CellTipsDelay = ((int)(resources.GetObject("tgridViewData.CellTipsDelay")));
			this.tgridViewData.CellTipsWidth = ((int)(resources.GetObject("tgridViewData.CellTipsWidth")));
			this.tgridViewData.ChildGrid = ((C1.Win.C1TrueDBGrid.C1TrueDBGrid)(resources.GetObject("tgridViewData.ChildGrid")));
			this.tgridViewData.CollapseColor = ((System.Drawing.Color)(resources.GetObject("tgridViewData.CollapseColor")));
			this.tgridViewData.ColumnFooters = ((bool)(resources.GetObject("tgridViewData.ColumnFooters")));
			this.tgridViewData.ColumnHeaders = ((bool)(resources.GetObject("tgridViewData.ColumnHeaders")));
			this.tgridViewData.DefColWidth = ((int)(resources.GetObject("tgridViewData.DefColWidth")));
			this.tgridViewData.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("tgridViewData.Dock")));
			this.tgridViewData.EditDropDown = ((bool)(resources.GetObject("tgridViewData.EditDropDown")));
			this.tgridViewData.EmptyRows = ((bool)(resources.GetObject("tgridViewData.EmptyRows")));
			this.tgridViewData.Enabled = ((bool)(resources.GetObject("tgridViewData.Enabled")));
			this.tgridViewData.ExpandColor = ((System.Drawing.Color)(resources.GetObject("tgridViewData.ExpandColor")));
			this.tgridViewData.ExposeCellMode = ((C1.Win.C1TrueDBGrid.ExposeCellModeEnum)(resources.GetObject("tgridViewData.ExposeCellMode")));
			this.tgridViewData.ExtendRightColumn = ((bool)(resources.GetObject("tgridViewData.ExtendRightColumn")));
			this.tgridViewData.FetchRowStyles = ((bool)(resources.GetObject("tgridViewData.FetchRowStyles")));
			this.tgridViewData.FilterBar = ((bool)(resources.GetObject("tgridViewData.FilterBar")));
			this.tgridViewData.FlatStyle = ((C1.Win.C1TrueDBGrid.FlatModeEnum)(resources.GetObject("tgridViewData.FlatStyle")));
			this.tgridViewData.Font = ((System.Drawing.Font)(resources.GetObject("tgridViewData.Font")));
			this.tgridViewData.GroupByAreaVisible = ((bool)(resources.GetObject("tgridViewData.GroupByAreaVisible")));
			this.tgridViewData.GroupByCaption = resources.GetString("tgridViewData.GroupByCaption");
			this.tgridViewData.Images.Add(((System.Drawing.Image)(resources.GetObject("resource"))));
			this.tgridViewData.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("tgridViewData.ImeMode")));
			this.tgridViewData.LinesPerRow = ((int)(resources.GetObject("tgridViewData.LinesPerRow")));
			this.tgridViewData.Location = ((System.Drawing.Point)(resources.GetObject("tgridViewData.Location")));
			this.tgridViewData.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.DottedCellBorder;
			this.tgridViewData.Name = "tgridViewData";
			this.tgridViewData.PictureAddnewRow = ((System.Drawing.Image)(resources.GetObject("tgridViewData.PictureAddnewRow")));
			this.tgridViewData.PictureCurrentRow = ((System.Drawing.Image)(resources.GetObject("tgridViewData.PictureCurrentRow")));
			this.tgridViewData.PictureFilterBar = ((System.Drawing.Image)(resources.GetObject("tgridViewData.PictureFilterBar")));
			this.tgridViewData.PictureFooterRow = ((System.Drawing.Image)(resources.GetObject("tgridViewData.PictureFooterRow")));
			this.tgridViewData.PictureHeaderRow = ((System.Drawing.Image)(resources.GetObject("tgridViewData.PictureHeaderRow")));
			this.tgridViewData.PictureModifiedRow = ((System.Drawing.Image)(resources.GetObject("tgridViewData.PictureModifiedRow")));
			this.tgridViewData.PictureStandardRow = ((System.Drawing.Image)(resources.GetObject("tgridViewData.PictureStandardRow")));
			this.tgridViewData.PreviewInfo.AllowSizing = ((bool)(resources.GetObject("tgridViewData.PreviewInfo.AllowSizing")));
			this.tgridViewData.PreviewInfo.Caption = resources.GetString("tgridViewData.PreviewInfo.Caption");
			this.tgridViewData.PreviewInfo.Location = ((System.Drawing.Point)(resources.GetObject("tgridViewData.PreviewInfo.Location")));
			this.tgridViewData.PreviewInfo.Size = ((System.Drawing.Size)(resources.GetObject("tgridViewData.PreviewInfo.Size")));
			this.tgridViewData.PreviewInfo.ToolBars = ((bool)(resources.GetObject("tgridViewData.PreviewInfo.ToolBars")));
			this.tgridViewData.PreviewInfo.UIStrings.Content = ((string[])(resources.GetObject("tgridViewData.PreviewInfo.UIStrings.Content")));
			this.tgridViewData.PreviewInfo.ZoomFactor = ((System.Double)(resources.GetObject("tgridViewData.PreviewInfo.ZoomFactor")));
			this.tgridViewData.PrintInfo.MaxRowHeight = ((int)(resources.GetObject("tgridViewData.PrintInfo.MaxRowHeight")));
			this.tgridViewData.PrintInfo.OwnerDrawPageFooter = ((bool)(resources.GetObject("tgridViewData.PrintInfo.OwnerDrawPageFooter")));
			this.tgridViewData.PrintInfo.OwnerDrawPageHeader = ((bool)(resources.GetObject("tgridViewData.PrintInfo.OwnerDrawPageHeader")));
			this.tgridViewData.PrintInfo.PageFooter = resources.GetString("tgridViewData.PrintInfo.PageFooter");
			this.tgridViewData.PrintInfo.PageFooterHeight = ((int)(resources.GetObject("tgridViewData.PrintInfo.PageFooterHeight")));
			this.tgridViewData.PrintInfo.PageHeader = resources.GetString("tgridViewData.PrintInfo.PageHeader");
			this.tgridViewData.PrintInfo.PageHeaderHeight = ((int)(resources.GetObject("tgridViewData.PrintInfo.PageHeaderHeight")));
			this.tgridViewData.PrintInfo.PrintHorizontalSplits = ((bool)(resources.GetObject("tgridViewData.PrintInfo.PrintHorizontalSplits")));
			this.tgridViewData.PrintInfo.ProgressCaption = resources.GetString("tgridViewData.PrintInfo.ProgressCaption");
			this.tgridViewData.PrintInfo.RepeatColumnFooters = ((bool)(resources.GetObject("tgridViewData.PrintInfo.RepeatColumnFooters")));
			this.tgridViewData.PrintInfo.RepeatColumnHeaders = ((bool)(resources.GetObject("tgridViewData.PrintInfo.RepeatColumnHeaders")));
			this.tgridViewData.PrintInfo.RepeatGridHeader = ((bool)(resources.GetObject("tgridViewData.PrintInfo.RepeatGridHeader")));
			this.tgridViewData.PrintInfo.RepeatSplitHeaders = ((bool)(resources.GetObject("tgridViewData.PrintInfo.RepeatSplitHeaders")));
			this.tgridViewData.PrintInfo.ShowOptionsDialog = ((bool)(resources.GetObject("tgridViewData.PrintInfo.ShowOptionsDialog")));
			this.tgridViewData.PrintInfo.ShowProgressForm = ((bool)(resources.GetObject("tgridViewData.PrintInfo.ShowProgressForm")));
			this.tgridViewData.PrintInfo.ShowSelection = ((bool)(resources.GetObject("tgridViewData.PrintInfo.ShowSelection")));
			this.tgridViewData.PrintInfo.UseGridColors = ((bool)(resources.GetObject("tgridViewData.PrintInfo.UseGridColors")));
			this.tgridViewData.RecordSelectors = ((bool)(resources.GetObject("tgridViewData.RecordSelectors")));
			this.tgridViewData.RecordSelectorWidth = ((int)(resources.GetObject("tgridViewData.RecordSelectorWidth")));
			this.tgridViewData.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("tgridViewData.RightToLeft")));
			this.tgridViewData.RowDivider.Color = ((System.Drawing.Color)(resources.GetObject("resource.Color")));
			this.tgridViewData.RowDivider.Style = ((C1.Win.C1TrueDBGrid.LineStyleEnum)(resources.GetObject("resource.Style")));
			this.tgridViewData.RowHeight = ((int)(resources.GetObject("tgridViewData.RowHeight")));
			this.tgridViewData.RowSubDividerColor = ((System.Drawing.Color)(resources.GetObject("tgridViewData.RowSubDividerColor")));
			this.tgridViewData.ScrollTips = ((bool)(resources.GetObject("tgridViewData.ScrollTips")));
			this.tgridViewData.ScrollTrack = ((bool)(resources.GetObject("tgridViewData.ScrollTrack")));
			this.tgridViewData.Size = ((System.Drawing.Size)(resources.GetObject("tgridViewData.Size")));
			this.tgridViewData.SpringMode = ((bool)(resources.GetObject("tgridViewData.SpringMode")));
			this.tgridViewData.TabAcrossSplits = ((bool)(resources.GetObject("tgridViewData.TabAcrossSplits")));
			this.tgridViewData.TabIndex = ((int)(resources.GetObject("tgridViewData.TabIndex")));
			this.tgridViewData.Text = resources.GetString("tgridViewData.Text");
			this.tgridViewData.ViewCaptionWidth = ((int)(resources.GetObject("tgridViewData.ViewCaptionWidth")));
			this.tgridViewData.ViewColumnWidth = ((int)(resources.GetObject("tgridViewData.ViewColumnWidth")));
			this.tgridViewData.Visible = ((bool)(resources.GetObject("tgridViewData.Visible")));
			this.tgridViewData.WrapCellPointer = ((bool)(resources.GetObject("tgridViewData.WrapCellPointer")));
			this.tgridViewData.Click += new System.EventHandler(this.c1TrueDBGrid1_Click);
			this.tgridViewData.PropBag = resources.GetString("tgridViewData.PropBag");
			// 
			// ItemCostDetail
			// 
			this.AccessibleDescription = resources.GetString("$this.AccessibleDescription");
			this.AccessibleName = resources.GetString("$this.AccessibleName");
			this.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize")));
			this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
			this.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin")));
			this.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize")));
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.CancelButton = this.btnClose;
			this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
			this.Controls.Add(this.btnClose);
			this.Controls.Add(this.btnHelp);
			this.Controls.Add(this.tgridViewData);
			this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
			this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode")));
			this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));
			this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this.MaximumSize")));
			this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this.MinimumSize")));
			this.Name = "ItemCostDetail";
			this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft")));
			this.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition")));
			this.Text = resources.GetString("$this.Text");
			this.Load += new System.EventHandler(this.ItemCostDetail_Load);
			((System.ComponentModel.ISupportInitialize)(this.tgridViewData)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void button8_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void c1TrueDBGrid1_Click(object sender, System.EventArgs e)
		{
		
		}

		//**************************************************************************              
		///    <Description>
		///       Form Load
		///        - Set Authorize for each button on form
		///        - Load data into grid
		///    </Description>
		///    <Inputs>
		///       
		///    </Inputs>
		///    <Outputs>
		///       Button will be disable or enable
		///    </Outputs>
		///    <Returns>
		///       
		///    </Returns>
		///    <Authors>
		///       THIENHD
		///    </Authors>
		///    <History>
		///       15-Dec-2004
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************
		private void ItemCostDetail_Load(object sender, System.EventArgs e)
		{
			const string METHOD_NAME = THIS + ".ItemCostDetail_Load()";
			try 
			{

				//check the input paramter
				if (intProductID <= 0 || intCCNID <= 0)
				{
					//MessageBox.Show("Please select a product and CCN for this form");
					PCSMessageBox.Show(ErrorCode.MESSAGE_SELECT_PRODUCT_CCN,MessageBoxIcon.Warning);
					this.Close();
					return;
				}
				//Set authorization for user
				
				Security objSecurity = new Security();
				this.Name = THIS;
				if(objSecurity.SetRightForUserOnForm(this, SystemProperty.UserName) == 0)
				{
					PCSMessageBox.Show(ErrorCode.MESSAGE_YOU_HAVE_NO_RIGHT_TO_VIEW,MessageBoxIcon.Warning);
					this.Close();
					return;
				}
				
				enumAction = new EnumAction();
				enumAction = EnumAction.Default;

				//Keep the Grid Design (for multi languages)
				KeepTheGridDesign();

				//Load ReturnedGoodsDetail
				LoadDetailData();
			}
			catch (PCSException ex) 
			{
				// displays the error message.
				PCSMessageBox.Show(ex.mCode,MessageBoxIcon.Error);
				// log message.
				try
				{
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION,MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// displays the error message.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR,MessageBoxIcon.Error);
				// log message.
				try
				{
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION,MessageBoxIcon.Error);
				}
			}
			
		
		}
	}
}
